package com.huige.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * @Author 朱志辉
 * @Create 2024/7/14 下午3:26
 * @Version 1.0
 * Description:   使用普通方式进行事务的添加
 */
@Component
@Aspect
public class TxAdvice {

    @Before("com.huige.pointcut.MyPointCut.pc()")
    public void  begin(JoinPoint joinPoint) {
        System.out.println("开启事务");
    }

    @AfterReturning("com.huige.pointcut.MyPointCut.pc()")
    public void commit() {
        System.out.println("提交事务");
    }

    @AfterThrowing("com.huige.pointcut.MyPointCut.pc()")
    public void rollback() {
        System.out.println("回滚事务");
    }


}
